class Money { 
    private int amount
    private String currency
    
    Money(amountValue, currencyValue) {
        amount = amountValue
        currency = currencyValue
    }
    
    boolean equals (Object other) {
        if ( null == other)                 return false
        if (! (other instanceof Money))     return false
        if (currency != other.currency)     return false
        if (amount != other.amount)         return false
        return true
    }
    
    int hasCode() {
        amount.hasCode + currency.hashCode
    }
    
    Money plus(Money other) {
        if (null        == other) return null
        if (other.currency != currency) {
            throw new IllegalArgumentException(
                        "cannot add $other.currency to $currency")
        }
        return  new Money(amount + other.amount, currency)
    }
}

def one = new Money(1, 'USD');
assert one
assert one       == new Money(1, 'USD')
assert one + one == new Money(2, 'USD')
def sum = one + one
println "one - $one.currency $one.amount"
println "sum - $sum.currency $sum.amount"
println "sum in runtime - ${(one + one).currency} ${(one + one).amount}"

sum = """
   Eso es todo amigos
           XD 
"""
println sum


